const request = require('request')
const AK = "itt6KN****dFqFms"
const SK = "HSQura****2LQVlV"

exports.main = async (event, context) => {
  let options = {
    'method': 'POST',
    'url': 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=' + AK + '&client_secret=' + SK,
  }
  return new Promise((resolve, reject) => {
    request(options, (error, response) => {
      if (error) {
        reject(error)
      } else {
        resolve(JSON.parse(response.body).access_token)
      }
    })
  })
  return data;
};